package com.xmut.mall.order.feign;

import com.xmut.mall.order.entity.OrderEntity;
import com.xmut.mall.order.entity.OrderItemEntity;
import com.xmut.mall.order.utils.RespBean;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

@FeignClient("mall-ware")
public interface WareFeignService {

    /**
     * 当订单被支付时解锁库存
     * @param param
     * @return
     */
    @PostMapping("/ware/waresku/unLockStockWhenOrderPayed")
    RespBean unLockStockWhenOrderPayed(@RequestBody Map<String, Object> param);

    /**
     * 获取sku的库存详情
     * @param skuId
     * @return
     */
    @GetMapping("/ware/waresku/getSkuWareNumber/{skuId}")
    RespBean getSkuWareNumber(@PathVariable Long skuId);

    /**
     * 创建锁库存工单
     * @param entity
     * @return
     */
    @PostMapping("/ware/waresku/createWareOrderTask")
    RespBean createWareOrderTask(@RequestBody OrderEntity entity);

    /**
     * 根据订单项锁商品库存
     * @param entity
     * @return
     */
    @PostMapping("/ware/waresku/lockStock")
    RespBean lockStock(@RequestBody OrderItemEntity entity);

    /**
     * 保存订单时修改锁库存工作单
     * @param entity
     * @return
     */
    @PostMapping("/ware/waresku/updateLockStockTask")
    RespBean updateLockStockTask(@RequestBody OrderEntity entity);

    /**
     * 测试feign
     * @return
     */
    @GetMapping("/ware/wareinfo/tsetFeign")
    RespBean tsetFeign();
}
